

#include "../kernel.h"
#include "../userid/userid.h"

#ifndef SAR_KERNEL_HANDLE_HANDLE_H
#define SAR_KERNEL_HANDLE_HANDLE_H

typedef unsigned int handle;
typedef size (* handle_Device) (handle _h, const char *_name);

#define BADHANDLE ((handle) -1)

void handle_init ();

handle handle_request (const char *_name, userid _u);
void handle_release (handle _h);
size handle_write (handle _h, const char *_buf, size _n);
size handle_writestring (handle _h, const char *_str);
size handle_read (handle _h, char *_buf, size _n);
size handle_peak (handle _h, char *_buf, size _n);
size handle_stringlength (handle _h);
void handle_unlock (handle _h);
int handle_trylock (handle _h);
int handle_source (handle _h, handle_Device _source);
int handle_sink (handle _h, handle_Device _sink);

#endif
